import 'package:fish_redux/fish_redux.dart' hide PageProvider;

import 'admin_user/admin_user_list_page/page.dart';
import 'admin_user/admin_user_edit_page/page.dart';

class PageProvider {
  static Map<String, PageProvider> get providers => _getProviders();
  static Map<String, PageProvider> _providers;
  static Map<String, PageProvider> _getProviders() {
    if (_providers == null) {
      _providers = {
        'admin_user_list': PageProvider(
          name: 'admin_user_list',
          label: '管理员管理',
          page: AdminUserListPage(),
        ),
        'admin_user_edit': PageProvider(
          name: 'admin_user_edit',
          label: '新建管理员',
          page: AdminUserEditPage(),
        ),
      };
    }

    return _providers;
  }

  static List<PageProvider> getMenus() {
    return [providers['admin_user_list']];
  }

  static Map<String, Page<Object, dynamic>> getRoutes() {
    Map<String, Page<Object, dynamic>> pages =
        providers.map((key, provider) => MapEntry(key, provider.page));
    return pages;
  }

  final String name;
  final String label;
  final Page page;

  PageProvider({
    this.name,
    this.label,
    this.page,
  });
}
